package com.nkzy.controller;

import com.nkzy.pojo.Bigevent;
import com.nkzy.service.BigeventService;
import com.nkzy.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bigevent")
public class BigeventController {

    @Autowired
    private BigeventService bigeventService;

    @GetMapping("/{id}")
    public Result<Bigevent> getBigeventById(@PathVariable Integer id) {
        Bigevent bigevent = bigeventService.getBigeventById(id);
        return Result.success(bigevent);
    }

    @GetMapping
    public Result<List<Bigevent>> getAllBigevent() {
        List<Bigevent> bigevents = bigeventService.getAllBigevent();
        return Result.success(bigevents);
    }

    @PostMapping
    public Result<Void> addBigevent(@RequestBody Bigevent bigevent) {
        bigeventService.addBigevent(bigevent);
        return Result.success();
    }

    @PutMapping
    public Result<Void> updateBigevent(@RequestBody Bigevent bigevent) {
        bigeventService.updateBigevent(bigevent);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result<Void> deleteBigevent(@PathVariable Integer id) {
        bigeventService.deleteBigevent(id);
        return Result.success();
    }
}